package org.begincode.admin.control;


import org.begincode.admin.service.ManagerService;
import org.begincode.core.model.UserManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;

/**
 * @Description: 登录验证
 */
@Controller
@RequestMapping("/user")
public class UserController {

	@Resource
	private ManagerService managerService;
	private Logger logger = LoggerFactory.getLogger(UserController.class);

	@RequestMapping(value = "/login", method = RequestMethod.POST)
	public String login(String username, String password) throws Exception {
		UserManager user = managerService.checkLogin(username, password);
		if (user != null) {
			logger.info("登陆成功");
			return "/admin/blogCheck";
		}
			logger.info("登陆失败");
			return "login";

	}
}